# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: get_data.py
Author: kij
Create Date: 2021/2/19
-------------------------------------------------
"""
import os
import json
from conf.config import BASE_DIR


def get_province():
	with open(os.path.join(BASE_DIR, "files", "china_city_data.json"), mode='r', encoding='utf-8') as file_city:
		city = json.load(file_city)  # json直接读取文件然后返回python数据类型
	return city

def set_city(city,address):
	print("选择学校地址")
	for num, value in enumerate(city, 1):
		print(num, value['name'])
	select = int(input("请输入:"))
	if not city[select-1].get('cityList'):
		address.append(city[select-1]['name'])
		return
	address.append(city[select-1]['name'])
	city = city[select-1]['cityList']
	set_city(city,address)



class City:
	def __init__(self, name, id, cityList):
		self.name = name
		self.id = id
		self.cityList = cityList
